package cn.tedu.charging.user.service.impl;

import cn.tedu.charging.common.pojo.vo.UserDetailVO;
import cn.tedu.charging.user.dao.mapper.UserMapper;
import cn.tedu.charging.user.pojo.param.LoginParam;
import cn.tedu.charging.user.pojo.po.UserPO;
import cn.tedu.charging.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 用户模块的业务层实现类
 * 实现 具体的业务逻辑
 */
@Slf4j
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public UserDetailVO detail(Integer id) {
        log.info("业务层-Service 用户详情,入参:{}", id);
        UserPO userPO = userMapper.selectById(id);
        UserDetailVO userDetailVO = new UserDetailVO();
        //如果查询结果不为空，将查询结果封装到 UserDetailVO 对象中
        if (userPO != null) {
            userDetailVO.setId(userPO.getId());
            userDetailVO.setNickName(userPO.getNickName());
            //不去查询用户车辆的绑定信息了 你们自己去实现 charging_user_vehicle_bind
            //我直接写死了 TODO
            userDetailVO.setCarId(666);
        }
//        userDetailVO.setId(id);
//        userDetailVO.setNickName("Tom");
        log.debug("业务层-Service 用户详情,入参:{},出参:{}", id, userDetailVO);
        return userDetailVO;
    }

    @Override
    public Integer login(LoginParam loginParam) {
        log.info("业务层-Service 登陆接口，入参：{}", loginParam);
        Integer userId = 666;
        log.debug("业务层-Service 登陆接口,入参:{},出参:{}", loginParam, userId);
        return 666;
    }

}